# Maintainer: Patrick Stewart <patstew@gmail.com>

_realname=mistune
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.8.4
pkgrel=2
pkgdesc="The fastest markdown parser in pure Python with renderer feature (mingw-w64)"
arch=('any')
url="https://github.com/lepture/mistune"
license=('BSD')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools")
source=("${_realname}-${pkgver}.tar.gz::https://github.com/lepture/mistune/archive/v${pkgver}.tar.gz")
sha256sums=('a1443771ea9ed7268a0cb3cf31462604ae148938ba32070bd5c54545f8f36a5d')

all_build() {
  cd "${srcdir}/${_realname}-${pkgver}"

  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/${1} setup.py install \
    --prefix=${MINGW_PREFIX} --root=${pkgdir} --optimize=1

  find "${pkgdir}/" -name "*.pyc" -delete
  find "${pkgdir}/" -type d -empty -delete
}

package_python3-mistune() {
  local interpreter=python3
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  all_build ${interpreter}

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-mistune() {
  local interpreter=python2
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  all_build ${interpreter}

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-mistune/LICENSE"
}

package_mingw-w64-i686-python2-mistune() {
  package_python2-mistune
}

package_mingw-w64-i686-python3-mistune() {
  package_python3-mistune
}

package_mingw-w64-x86_64-python2-mistune() {
  package_python2-mistune
}

package_mingw-w64-x86_64-python3-mistune() {
  package_python3-mistune
}
